Imports Phoenix.Forms

Namespace Helpers

    Public Class BaseHelper

#Region " Shared Helpers "
        Public Shared Function IsNew(ByVal row As DataRow) As Boolean
            Return row.RowState = DataRowState.Detached
        End Function

        Public Shared Function IsDeleted(ByVal row As DataRow) As Boolean
            Return row.RowState = DataRowState.Deleted
        End Function

        Private Shared mTag As Hashtable = New Hashtable
        Protected Shared Property Tag(ByVal obj As DataRow) As Object
            Get
                Return mTag(obj)
            End Get
            Set(ByVal Value As Object)
                If Value Is Nothing Then
                    mTag.Remove(obj)
                Else
                    mTag(obj) = Value
                End If
            End Set
        End Property

        Private Shared mOpenartionCanceled As Boolean
        Protected Shared Property OperationCanceled() As Boolean
            Get
                Return mOpenartionCanceled
            End Get
            Set(ByVal Value As Boolean)
                mOpenartionCanceled = Value
            End Set
        End Property

        Protected Shared Function CloseForm(ByVal row As DataRow) As Boolean
            Dim form As ChildFormBase = ChildFormBase.FindForm(row)
            If form Is Nothing Then
                Return True
            Else
                form.Close()
                If form.Visible Then
                    OperationCanceled = True
                    Return False
                Else
                    Return True
                End If
            End If
        End Function

#End Region

    End Class

End Namespace
